<?php

/* @var $this \yii\web\View */
/* @var $content string */

use yii\helpers\Html;

$web = \yii\helpers\Url::base();
$url = \app\librarys\Tools::urlBase();
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="x-ua-compatible" content="IE=10">
    <title>系统登录</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="<?= $web ?>/css/bootstrap.css">
    <link rel="stylesheet" href="<?= $web ?>/css/frame.css">
    <!--<link rel="stylesheet" href="css/login.css">-->
    <!--[if IE]>
    <link rel="stylesheet" type="text/css" href="<?= $web?>/css/ie.css"/>
    <![endif]-->
    <script src="<?= $web ?>/js/jquery-1.11.3.js"></script>
    <script src="<?= $web ?>/js/bootstrap.js"></script>
    <script src="<?= $web ?>/js/frame.js"></script>
    <script>
    </script>
</head>
<body>
<div class="login-main">
    <div class="login">
        <div class="login-logo"></div>
        <form id="login-form" action="<?= $url ?>/site/login?return_url=<?= $return_url ?>" method="post">
            <div class="login-content-wrapper">
                <div class="login-content-wrapper-bg"></div>
                <div class="login-content">
                    <div class="alert alert-danger login-alert hidden" role="alert" id="login-alert">
                        <span class="glyphicon glyphicon-exclamation-sign alert-icon" aria-hidden="true"></span>
                        <span class="sr-only"></span>
                        <span class="alert-txt">你输入的密码和账户名不匹配</span>
                        <span class="glyphicon glyphicon-remove form-control-feedback" aria-hidden="true"
                              onclick="closeAlert('login-alert')"></span>
                    </div>

                    <div class="item-login">
                        <input type="text" id="account" name="LoginForm[account]" value="<?= $model->account ?>"
                               class="form-control" placeholder="用户名" autofocus>
                        <span class=" user-icon"></span>
                    </div>

                    <div class="item-login">
                        <input type="password" style="display: none">
                        <input type="password" id="password" name="LoginForm[password]" value="<?= $model->password ?>"
                               class="form-control" placeholder="密码">
                        <span class="password-icon"></span>
                    </div>
                    <!-- <div class="login-info">
                        <label class="input-checkbox">
                            <input type="checkbox" class="label--input-inline" name="LoginForm[rememberMe]">
                            <span class="login-info-txt">请保存我这次的登录信息。</span>
                        </label>
                    </div>-->
                    <input type="submit" class="btn btn-primary btn-login" value="登录">

                </div>
            </div>
            <input type="hidden" name="init" value="0">
        </form>
        <div class="opyright">Copyright © 2006-2017 hy.com All Rights Reserved.</div>
    </div>
</div>
<script>
    function closeAlert(id) {
        $("#" + id).toggle(false);
    }

    if (<?= !$post['init'] ? "true" : "false"?>) {
        if (<?= (isset($model->getErrors()['account'])) ? "true" : "false"?> && <?= (isset($model->getErrors()['password'])) ? "true" : "false"?>)
        {
            $("#login-alert").removeClass("hidden");
            $("#login-alert").find(".alert-txt").html("用户名和密码不能为空");
        }
    else
        if (<?= (isset($model->getErrors()['account']) && $model->getErrors()['account'][0] == "Account cannot be blank.") ? "true" : "false"?>) {
            $("#login-alert").removeClass("hidden");
            $("#login-alert").find(".alert-txt").html("用户名不能为空");
        } else if (<?= (isset($model->getErrors()['password']) && $model->getErrors()['password'][0] == "Password cannot be blank.") ? "true" : "false"?>) {
            $("#login-alert").removeClass("hidden");
            $("#login-alert").find(".alert-txt").html("密码不能为空");
        } else if (<?= (isset($model->getErrors()['password']) && $model->getErrors()['password'][0] == "ERROR") ? "true" : "false"?>) {
            $("#login-alert").removeClass("hidden");
            $("#login-alert").find(".alert-txt").html("帐号或密码错误");
        }
    }


</script>
</body>
</html>